1. Field of the Invention
The invention relates to virtual machine session data management. Specifically, the invention relates to copying data to a shared closure only on demand.
2. Background
In object oriented environments, such as the Java® platform by Sun Microsystems of Santa Clara, Calif., virtual machines are used to execute code for the platform. The virtual machines are executed by operating system processes and can be used to provide a server framework. The server framework may in turn provide a session manager and support a number of applications and similar services to clients. The state of each of the applications or application interfaces is referred to as a user session.
During the runtime of a platform a virtual machine may fail. As a result, user session data can be lost, causing loss of data and service for users. One common technique to protect against this loss is to store user session data in a persistent storage that is not affected by virtual machine failures. This technique is often referred to as ‘session failover’. As a prerequisite for session failover, it must be possible to convert all objects that represent the user session into a form that may be stored in a persistent storage. Serialization is a feature of the Java® platform that allows objects to be transformed into a byte stream that may be stored in a persistent storage. Using this technique, all session objects are required to be serializable. A serializable object can be restored after session failover by the same virtual machine or another virtual machine. When a session manager determines that a session is to be persisted for storage in a persistent storage device, the complete user session is serialized and stored. However, this process involves a high performance cost. Converting and storing the objects of the session is a relatively slow process and diminishes overall system performance.
An alternative method of handling session failover utilizes shared closures. Shared closures provide an alternative mechanism for converting objects into a persistent form. In order to be usable with shared closures, session objects must be serializable and conform to additional restrictions to ensure that they can be transformed into their persistent state without having to execute user code. In this method a shared storage is utilized to allow multiple virtual machines to access the session objects and related data objects or ‘shared closures.’ A shared closure is an initial data object and transitive closure of all the objects that are references by this data object. These shared closures persist in shared memory even if a virtual machine fails. The session manager creates a shared closure for session objects instead of serializing them. Objects belonging to a session are traversed by the virtual machine code and copied to a shared memory block. This process is much faster than serialization.
However, session object data is still traversed and copied to the shared closure, which is only of benefit if the next request for the session is going to be processed in a different virtual machine. This traversal and copying occurs each time that something changes in the session data. In the case where the next request for the session data is from the same virtual machine, then the effort spent to copy the session data to the shared memory is wasted and the efficiency of the system reduced.